package  com.test;

import com.DBConfig.DBUtil;
import org.junit.Test;

import java.sql.*;
import java.util.Date;

public class test {
    @Test
    public void test(){
        Connection conn = DBUtil.getConn();
        PreparedStatement ptst = null;
        ResultSet result = null;

        try {
            ptst = conn.prepareStatement("SELECT * FROM user where name = ? and password = ?");
            ptst.setString(1,"admin");
            ptst.setString(2,"admin");
            result = ptst.executeQuery();
            while (result.next()) {
                String name = result.getString("name");
                String password = result.getString("password");
                System.out.println(name+"\n"+password);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                result.close();
                ptst.close();
            } catch (Exception e){

            }
        }
    }
}
